define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope, Predepositwater, GoPage) {
		
		//页面激活
		$scope.$on('$ionicView.afterEnter', function() {
			$scope.init_data();//必须放在这里，否则切换账号时，看到的预存款是一样的
		}, false);
		
		//初始化页面
		$scope.init_data = function(){
			Predepositwater.getAdvance(function(data){
				$scope.total_advance = data.total_advance;
				console.log(data)
			})
		}
		
		$scope.gotoDeposit = function() {
			GoPage.go_states("predeposit");
		}
		
		$scope.show_detail = function() {
			GoPage.go_states("predepositdetails");
		}
		
	}

	controller.$inject = ['$scope', 'Predepositwater', 'GoPage'];
	
	return app.registerController("predepositwaterctrl",controller);
});